<p>A non-serializable <code>Comparator</code> can prevent an otherwise-<code>Serializable</code> ordered collection from being serializable. Since the
overhead to make a <code>Comparator</code> serializable is usually low, doing so can be considered good defensive programming.</p>
<h2>Noncompliant Code Example</h2>
<pre>
public class FruitComparator implements Comparator&lt;Fruit&gt; {  // Noncompliant
  int compare(Fruit f1, Fruit f2) {...}
  boolean equals(Object obj) {...}
}
</pre>
<h2>Compliant Solution</h2>
<pre>
public class FruitComparator implements Comparator&lt;Fruit&gt;, Serializable {
  private static final long serialVersionUID = 1;

  int compare(Fruit f1, Fruit f2) {...}
  boolean equals(Object obj) {...}
}
</pre>

